package com.mc.book.hutool;

import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;

public class TimedCacheUtils {

    private static final TimedCache<String, String> TIMED_CACHE = CacheUtil.newTimedCache(1000*60);

    /**
     * 存入键值对，添加过期时间，和消费回调
     *
     * @param key
     * @param timeout
     * @param consumer
     */
    public static void put(String key, String value) {
        TIMED_CACHE.put(key, value);
    }

    /**
     * 获取缓存值
     *
     * @param key
     * @return
     */
    public static String get(String key) {
        return TIMED_CACHE.get(key,false);
    }

    /**
     * 删除缓存和回调映射
     *
     * @param key
     */
    public static void remove(String key) {
        TIMED_CACHE.remove(key);
    }



}
